import {createRouter, createWebHashHistory, createWebHistory} from 'vue-router'
// @ts-ignore
import {Utils} from "@/utils/utils";
import Layout from "@/layout/Layout.vue";

const constantRoutes = [
    {
        path: "/:pathMatch(.*)*",
        name: "notFound",
        component: () => import('@/views/404.vue'),  // 引入 组件
    },{
        path: '/register',
        name: 'Register',
        component: () => import('@/views/Register.vue'),  // 引入 组件
    },{
        path: '/login',
        name: 'Login',
        component: () => import('@/views/Login.vue'),  // 引入 组件
    },{
        path: '/',
        component: Layout,
        redirect:'/home',
        children:[{
            path: '/home',
            name: '首页',
            component: () => import('@/views/Home.vue'),  // 引入 组件
        },{
            path: '/user',
            name: '绑定',
            component: () => import('@/views/User.vue'),  // 引入 组件
        },{
            path: '/manage',
            name: '管理类',
            redirect: '/manage/vacate',
            children:[{
                path: '/manage/vacate',
                name: '请销假管理',
                component: () => import('@/views/manage/Vacate.vue'),  // 引入 组件
            },{
                path: '/manage/apply',
                name: '审批管理',
                component: () => import('@/views/manage/Apply.vue'),  // 引入 组件
            },{
                path: '/manage/person',
                name: '人员管理',
                component: () => import('@/views/manage/Person.vue'),  // 引入 组件
            },{
                path: '/manage/department',
                name: '部门管理',
                component: () => import('@/views/manage/Department.vue'),  // 引入 组件
            },{
                path: '/manage/authority',
                name: '手机授权',
                component: () => import('@/views/manage/Authority.vue'),  // 引入 组件
            }]
        },{
            path: '/party',
            name: '评估管理',
            redirect: '/party/info',
            children: [{
                path: '/party/info',
                name: '评估列表',
                component: () => import('@/views/party/Index.vue'),
            },{
                path: '/party/config',
                name: '指标配置',
                component: () => import('@/views/party/Config.vue'),
            },{
                path: '/party/rank',
                name: '等次配置',
                component: () => import('@/views/party/RankAdjust.vue'),
            }]
        },{
            path: '/party/name',
            name: '党组织配置',
            component: () => import('@/views/party/NameConfig.vue'),  // 引入 组件
        }]
    }]

const router = createRouter({
    history: createWebHistory(),
    routes: constantRoutes,
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition
        } else {
            return { top: 0 }
        }
    },
})

export default router;
